//
//  LYNONetworkView.m
//  newsapp
//
//  Created by 雷国敏 on 16/7/13.
//  Copyright © 2016年 lieyunwang. All rights reserved.
//

#import "LYNONetworkView.h"
@interface LYNONetworkView()
@property (weak, nonatomic) IBOutlet UIActivityIndicatorView *indicatorView;
@property (weak, nonatomic) IBOutlet UILabel *nonetworkLable;

@end

@implementation LYNONetworkView

- (instancetype)init
{
	self = [super init];
	if (self) {
		self = [[[NSBundle mainBundle] loadNibNamed:@"LYNONetworkView" owner:self options:nil] lastObject];
		
		//设置UI
		[self setupUI];
	}
	return self;
}



/**
 * 设置UI
 */
-(void)setupUI{
	self.x = 0;
	self.y = -64;
	self.backgroundColor = [UIColor colorWithHexString:@"#10D45F"];
	
	//1.设置宽度
	self.width = NEWS_IP_DEVICE_WIDTH;
	self.nonetworkLable.font = [UIFont gm_adaptiveFontSize:_nonetworkLable.font.pointSize];
	//2.设置菊花旋转
	[self.indicatorView setCenter:CGPointMake(80, 70)];//指定进度轮中心点
	[self.indicatorView setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];//设置进度轮显示类型
	[self.indicatorView startAnimating];
}




-(void)gm_showNoNetwork{
	self.userInteractionEnabled = NO;
	[[[UIApplication sharedApplication] keyWindow] addSubview:self];
	
	[UIView animateWithDuration:0.5 animations:^{
		self.y += 64;
	}completion:^(BOOL finished) {
		self.y = 0;
		dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(),^{
			[UIView animateWithDuration:1 animations:^{
				self.y -= 64;
			}completion:^(BOOL finished) {
				self.y = -64;
				[self removeFromSuperview];
				self.userInteractionEnabled =YES;
			}];
		});
	}];
	
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
